var request = require('request');
// var serverHome = require('../config');
exports.nullDataReq=function(req,key,Dpath,Dpost,success){ 
    var options = {
        url: global.host+Dpath,
        method: Dpost,
        headers :{
            apikey:key,
            ContentType :"application/json;charset=utf-8"
        }
        
    };

    function callback(error, response, data) {

        if (!error && response.statusCode == 200) {
            success(data);
        }
    
    }   
    request(options, callback);

}
exports.dataReq=function(req,data,key,Dpath,Dpost,success){ 
    var options = {
        url: global.host+Dpath,
        method: Dpost,
        json:true,
        body:data,
        headers :{
            apikey:key,
            ContentType :"application/json;charset=utf-8"
        }
    };
    function callback(error, response, data) {
        if (!error && response.statusCode == 200) {
            success(data);
        }
    }  
    request(options, callback);

}

exports.importfileReq=function(req,data,key,Dpath,Dpost,success){ 
    var options = {
        url: global.host+Dpath,
        method: Dpost,
        body:data,
        headers :{
            apikey:key
        }
    };
    function callback(error, response, data) {
        if (!error && response.statusCode == 200) {
            success(data);
        }
    }   
    request(options, callback);

}
exports.loginDataReq=function(req,data,Dpath,Dpost,success){ 
    var options = {
        url:global.host+Dpath,
        method: Dpost,
        contentType: "application/json;charset=utf-8",
        json:true,
        body:data
    };
    function callback(error, response, data) {
        if (!error && response.statusCode == 200) {
            success(data);
        }
    
    }   
    request(options, callback);

}           
        
 exports.delEmptyValue=function(data){
    for(var i in data){
      if(data[i]=='' || data[i]==null || data[i]==undefined){
        delete data[i];
      }
    }
    return data;
 }   






